
import java.io.File;
import java.io.Serializable;

class Track implements Serializable{

    //Track's location in this host
    private String location;

    //Track's title
    private String title;

    //Track's creator
    private String creator;

    //Track's album
    private String album;

    //Track's year the album was released
    private String year;

    //Track's genre
    private String genre;

    //Track's lyrics
    private String lyric;

    //Track's composer
    private String composer;

    //Track's hoster
    private String serverName;

    //Track's hoster
    private String nodeName;

    /**
    * This object stores necesary information for finding a track between nodes
    */
    public Track(String location, String title, String creator, String album, String year,
                 String genre, String lyric, String composer, String nodeName)
    throws TrackException
    {

    if (null == location){
        throw new TrackException("No se especificó la ubicación del archivo");
    }
    if (null == title){
        throw new TrackException("No se especificó el nombre de la canción");
    }
    if (null == creator){
        throw new TrackException("No se especificó el creador de la canción");
    }
    if (null == nodeName){
        throw new TrackException("No se especificó el nombre de nodo de la canción");
    }

    this.location = location;
    this.title = title;
    this.creator = creator;
    this.album = album;
    this.year = year;
    this.genre = genre;
    this.lyric = lyric;
    this.composer = composer;
    this.nodeName = nodeName;
    }

    /**
     * Method that compares to tracks for equality
     */
    public boolean equals(Track t){
        if(this.title.equals(t.getTitle()) && this.creator.equals(t.getCreator()) && this.nodeName.equals(t.getNodeName()))
            return true;

        return false;
    }

    public String getLocation(){
        return location;
    }

    public String getCreator(){
        return creator;
    }

    public String getTitle(){
        return title;
    }

    public String getAlbum(){
        return this.album;
    }

    public String getYear(){
        return this.year;
    }
    public String getGenre(){
        return this.genre;
    }
    public String getLyric(){
        return this.lyric;
    }
    public String getComposer(){
        return this.composer;
    }

    public String getNodeName(){
        return nodeName;
    }

    public void setServerName(String serverName){
        this.serverName = serverName;
    }

    public String getServerName(){
        return serverName;
    }

    /**
    * String representation of this track. It is for debugging purposes
    */
    public String toString(){
    return "title: " + title +
            " creator: " + creator +
            " location: " + location +
            " serverName: " + serverName;
    }
}